package com.xmuexp109.exp5.model;

import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * 订单明细
 **/
@Data
public class ordersRetVo {
    private Long id;

    private Long customerId;

    private Long shopId;

    private String orderSn;

    private Long pid;

    private String consignee;

    private Long regionId;

    private String address;

    private String mobile;

    private String message;

    private Byte orderType;

    private Long freightPrice;

    private Long couponId;

    private Long couponActivityId;

    private Long discountPrice;

    private Long originPrice;

    private Long presaleId;

    private Long grouponDiscount;

    private Integer rebateNum;

    private Date confirmTime;

    private String shipmentSn;

    private Byte state;

    private Byte substate;

    private Byte beDeleted;

    private Date gmtCreate;

    private Date gmtModified;

    private Long grouponId;

    private List<orderItemRetVo> orderItemList;

    /**
     * 构造函数，由orders对象创建RetVo
     * @param orders orders对象
     */
    public ordersRetVo(orders orders) {
        this.id = orders.getId();
        this.orderSn=orders.getOrdersn();
        this.pid=orders.getPid();
        this.orderType=orders.getOrderType();
        this.state=orders.getState();
        this.substate=orders.getSubstate();
        this.gmtCreate=orders.getGmtCreate();
        this.gmtModified=orders.getGmetModified();
        this.confirmTime=orders.getConfirmTime();
        this.originPrice=orders.getOriginPrice();
        this.discountPrice=orders.getDiscountPrice();
        this.freightPrice=orders.getFreightPrice();
        this.rebateNum=orders.getRebateNum();
        this.message=orders.getMessage();
        this.regionId=orders.getRegionId();
        this.address=orders.getAdress();
        this.mobile=orders.getMobile();
        this.consignee=orders.getConsignee();
        this.couponId=orders.getCouponId();
        this.grouponId=orders.getGrouponId();
        this.presaleId=orders.getPresaleId();
        this.shipmentSn=orders.getShipmentSn();

        if (null != orders.getOrderItemList()) {
            List<orderItemRetVo> orderItemList = new ArrayList<>(orders.getOrderItemList().size());

            for (orderItem orderItem : orders.getOrderItemList()) {
                orderItemRetVo orderItemrVo = new orderItemRetVo(orderItem);
                orderItemList.add(orderItemrVo);
            }
            this.orderItemList = orderItemList;
        }
    }
}
